﻿using TraumaCenterSystem.Code.Bll;
using TraumaCenterSystem.Core;
using TraumaCenterSystem.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TraumaCenterSystem.Areas.TraumaCenter.Controllers
{
    public class DoctorAdviceController : BaseController
    {
        //
        // GET: /TraumaCenter/DoctorAdvice/
        /// <summary>
        /// 医嘱查询页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 查询医嘱列表
        /// </summary>
        /// <returns></returns>
        public ContentResult Search()
        {
            string triageId = WebUtils.GetString("triageId");
            string date = WebUtils.GetString("date");
            if (!string.IsNullOrEmpty(date)) date += ":00";
            else
                date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
            DateTime dt = Convert.ToDateTime(date);
            //调取数据
            OperateResult result = DoctorAdviceManager.GetOrderData(triageId, dt);

            //加载数据
            if (result.Result == 1)
            {
                string printStatus = WebUtils.GetString("printStatus");
                string typecode = WebUtils.GetString("typecode");
                string effectFlg = WebUtils.GetString("effectFlg");
                result = DoctorAdviceManager.getOrderForm(triageId, printStatus, typecode, dt.ToString("yyyy-MM-dd HH:mm:ss"), effectFlg);
                if (result.Result == 1)
                {
                    return JsonDate(result);
                }
            }
            return JsonDate(result);
        }

    }
}
